<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title></title>
</head>

<body>

    <text>12</text>

    <script>
        var text = document.querySelector("text");
        console.log(text);
        if (navigator.geolocation) {
            console.log("调用定位");
            navigator.geolocation.getCurrentPosition(successCallback, errorCallback);
        } else {
            console.log("不支持定位");
        }

        function successCallback(position) {
            var wd = position.coords.latitude; //纬度
            var js = position.coords.longitude;//精度

            console.log("wd===" + wd + ";;;jd=" + js);
            text.innerHTML = wd + " '''jd==" + js;
        }

        function errorCallback(err) {
            console.log(err);
            console.log("获取位置失败");
        }
    </script>

</body>

</html>